<nav class="navbar navbar-expand-lg bg-body-tertiary shadow-sm my_navbar ">
    <div class="container">
        <a class="navbar-brand d-flex justify-content-start align-items-center" href="{{route('root')}}">
            <img width="32" class="d-inline-block align-text-center me-2" src="{{url('pics/logo/laravel.png')}}"
                 alt="logo">
            MyChat
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link {{active_class(if_route('topics.index'))}}"
                       aria-current="page" href="{{route('topics.index')}}">帖子</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(1)}}" href="{{route('categories.show',1)}}">文化</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(2)}}" href="{{route('categories.show',2)}}">体育</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(3)}}" href="{{route('categories.show',3)}}">旅行</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(4)}}" href="{{route('categories.show',4)}}">美食</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(5)}}" href="{{route('categories.show',5)}}">历史</a>
                </li>
            </ul>
            <ul class="navbar-nav">
                @guest
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('register')}}">注册</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('login')}}">登录</a>
                    </li>
                @else
                    @can('manage_contents')
                    <li class="nav-item d-flex align-items-center">
                        <a class="text-decoration-none fa-solid fa-gauge px-2"
                           href="{{url(config('administrator.uri'))}}"
                           title="后台管理">
                        </a>
                    </li>
                    @endcan
                    <li class="nav-item d-flex align-items-center">
                        <a class="text-decoration-none fa-solid fa-plus px-2"
                           href="{{route('topics.create')}}"
                           title="发布帖子">
                        </a>
                    </li>
                    <li class="nav-item d-flex align-items-center">
                        <a class="text-decoration-none px-2 text-{{Auth::user()->notification_count > 0 ? 'danger' : 'secondary'}} d-flex align-items-center"
                           href="{{route('notifications.index')}}"
                           title="消息通知">
                            <i class="fa-solid fa-bell me-1"></i>
                            <span class="badge rounded-pill  text-bg-{{Auth::user()->notification_count > 0 ? 'danger' : 'secondary'}}">
                                {{Auth::user()->notification_count}}
                            </span>
                        </a>
                    </li>
                    <li class="nav-item dropdown">

                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
                           aria-expanded="false">
                            @include('shared._avatar',['avatar'=>Auth::user()->avatar,'width'=>40,'is_border'=>'show'])
                            {{Auth::user()->name}}
                        </a>
                        <ul class="dropdown-menu">
                            <li class="text-center">
                                <a class="dropdown-item" href="{{route('users.show',Auth::id())}}">
                                    <i class="fa-solid fa-user-tie"></i>
                                    个人空间
                                </a>
                            </li>
                            <li class="text-center">
                                <a class="dropdown-item" href="{{route('users.edit',Auth::id())}}">
                                    <i class="fa-solid fa-pen-to-square"></i>
                                    编辑资料
                                </a>
                            </li>
                            <li>
                                <hr class="dropdown-divider">
                            </li>
                            <li class="text-center">
                                <form action="{{route('logout')}}" method="POST">
                                    {{csrf_field()}}
                                    <button class="btn btn-sm btn-danger" type="submit">
                                        <i class="fa-solid fa-arrow-right-from-bracket"></i>
                                        退出
                                    </button>
                                </form>
                            </li>
                        </ul>
                    </li>
                @endguest

            </ul>
        </div>
    </div>
</nav>
